﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Phatent.Model.Accounts;
namespace Phatent.Command.Accounts
{
    public class UserCommand
    {
        public static UserModel GetUser(string username, string password)
        {
            if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
            {
                using (DBCentre db = new DBCentre())
                {
                    var d = db.DataContext.Users.FirstOrDefault(p => p.UserName == username && p.Password == password);
                    if (d != null)
                    {
                        var ret = Convertor.ConvertTo<UserModel, User>(d);
                        return ret;
                    }
                }
            }
            return null;
        }
    }
}
